<?php
	function f601($sql){
		//data handle instance
		//set request
		//define format
		//set format
		//define query string
		//process time
		//process fitler
		$dataHandle = new DataHandle();
		$dataHandle->setRequest("601");

		$action = getValue($_GET['action']);

		if ($action == "getItems"){
			$format = array(
				"date" => "datem/d/Y",
				"modified_date" => "datem/d/Y",
			);

			$dataHandle->setFormat($format);
			$query = getJSONQuery();
			print($dataHandle->printJSON($sql, $query));
		}
		else if($action == "addItems"){
			var_dump($dataHandle->addItemsQuery($sql,$_GET,"lin_Holidays_custom"));
		}
		else if($action == "updateItems"){
			var_dump($dataHandle->updateItemsQuery($sql,$_GET, "lin_Holidays_custom"));
		}
		else if($action == "deleteItems"){
			var_dump($dataHandle->deleteItemsQuery($sql,$_GET, "lin_Holidays_custom"));
		}
		else{
			$temp = array();
			$temp['error'] = "601: Bad request";
			print(json_encode($temp));
		}

		unset($dataHandle);

	}

	function getJSONQuery(){

		$queryString = "
			SELECT 
			    date,
			    event,
			    modified_by,
			    modified_date
			FROM lin_Holidays_custom";

		$oderByFiled = getValue($_GET['sortItem']);
		$oderByValue = getValue($_GET['ascDesc']);

		if($oderByFiled !== "" and $oderByValue !== "")
			$queryString = $queryString." order by ".$oderByFiled." ".$oderByValue;

		return $queryString;
	}
?>